package com.link.base.base.performance.controller;

import com.link.base.base.performance.model.Bonus;
import com.link.base.base.performance.service.BonusService;
import com.link.core.basic.annotations.JsonParam;
import com.link.core.basic.controller.BasicController;
import com.link.core.basic.service.BasicService;
import com.link.core.basic.service.KeyGenerateService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.util.HashMap;
import java.util.Map;

/**
 * 年度奖金
 *
 * @author 王昊
 * @date 2021-04-08 11:34:34
 */
@Controller
@RequestMapping("/link/bonus")
public class BonusController extends BasicController<Bonus> {

    @Resource
    private KeyGenerateService keyGenerateService;

    @Resource
    private BonusService bonusService;

    @Override
    public BasicService<Bonus> getBasicService() throws Exception {
        return bonusService;
    }

    /**
     * 年度奖金审批
     * @author 王昊
     * @param entity
     * @param session
     * @param request
     * @return
     */
    @RequestMapping(value = "/bonusSubmit" , method = RequestMethod.POST)
    @ResponseBody
    public Map<String,Object> bonusSubmit(@JsonParam Bonus entity, HttpSession session, HttpServletRequest request) {
        Map<String,Object> result = new HashMap<>(4);
        try {
            bonusService.bonusSubmit(entity);
            result.put("newRow",entity);
            result.put("success",true);
        } catch (Exception e) {
            result.put("success",false);
            result.put("result", e.getMessage());
        }
        return result;
    }

}